<template>
    <view>
        <video id="myVideo" :src="videoSrc"
        @error="videoErrorCallback" :danmu-list="danmuList" autoplay object-fit="contain" enable-danmu danmu-btn controls>
        </video>
        <button class="share-btn" open-type="share">
            分 享
        </button>
        
    </view>
</template>

<script setup>
import { ref } from 'vue';
import { onLoad, onShow,onShareAppMessage,onShareTimeline } from '@dcloudio/uni-app'
const danmuList = ref([]);
const videoSrc = ref('https://jiushenggu.oss-cn-nanjing.aliyuncs.com/WeChat_20250605103759.mp4');
const img = ref('')
const videoErrorCallback = (e) => {
    console.log('视频加载失败', e);
}

onLoad((option)=>{
    console.log('option',JSON.parse(option.item))
    videoSrc.value = JSON.parse(option.item).mp4
    img.value = JSON.parse(option.item).img 
})

// 分享配置
onShareAppMessage(() => {
    return {
        title: '玖盛谷台球俱乐部',
        path: '/pages/video/videoDetail',
        imageUrl:img.value,
    }
})

// 分享朋友圈
onShareTimeline(()=>{ 
    return {
        title:'玖盛谷台球俱乐部',
        path: '/pages/video/videoDetail',
        desc:'玖盛谷台球俱乐部',
        imageUrl:img.value,
    }
})

</script>

<style scoped>
#myVideo {
    width: 100vw;
    height: 100vh;
} 

.share-btn {
    position: fixed;
    width: 100rpx;
    height: 80rpx;
    line-height: 80rpx;
    /* text-align: center; */
    bottom: 120rpx;
    right: 20rpx;
    background-color: rgba(0, 0, 0, 0.5);
    color: #ffffff;
    border: none;
    border-radius: 40rpx;
    font-size: 12px;
    z-index: 999;
    padding: 0;
}
</style>